//
//  LSLoginViewController.swift
//  niceapp-ios
//
//  Created by sujeking on 2017/8/1.
//  Copyright © 2017年 szw. All rights reserved.
//

import UIKit
import SocketRocket
import YYKit
import FFToast


class LSLoginViewController: UIViewController {
    
    @IBOutlet weak var loginBtn: UIButton!
    
    @IBOutlet weak var unameTextField: UITextField!
    
    @IBOutlet weak var upassTextField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupUI()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    // MARK: - Init
    func setupUI() {
        self.loginBtn.layer.cornerRadius = CGFloat(self.loginBtn.bounds.height/2)
        self.loginBtn.backgroundColor = #colorLiteral(red: 0.1568627451, green: 0.4588235294, blue: 0.9843137255, alpha: 1)
        self.loginBtn.layer.shadowColor = #colorLiteral(red: 0.1568627451, green: 0.4588235294, blue: 0.9843137255, alpha: 1).cgColor
        self.loginBtn.layer.shadowOffset = CGSize(width: 0, height: 2)
        self.loginBtn.layer.shadowOpacity = 1
        self.loginBtn.layer.shadowRadius = 5
    }
    
    @IBAction func loadChatVC(_ sender: Any) {
        if self.unameTextField.text?.characters.count == 0 {
            let toast = FFToast.init(toastWithTitle: "提示", message: "用户名不能为空", iconImage: nil) as FFToast
            toast.toastBackgroundColor = #colorLiteral(red: 0.4, green: 0.4941176471, blue: 0.9176470588, alpha: 1)
            toast.duration = 3
            toast.show()
            return;
        }
        
        let uname = self.unameTextField.text
        
        ud.set(uname, forKey: "uname")
        ud.synchronize()
        
        let chatVC = LSUtil.viewControllerWithIndetififer(indetififer: "LSChatViewController")
        self.navigationController?.wxs_pushViewController(chatVC, makeTransition: { (wxs) in
            wxs?.animationType = LSTransitionAnimationType.sysCubeFromRight
            wxs?.backGestureEnable = false
            wxs?.animationTime = 0.5
        })
    }
}
